package com.homework;

import java.util.Scanner;

/**
 * 描述: 披萨测试
 *
 * @author CodeYang
 * @version 2020/12/17 9:42
 */
public class PizzaHomework02 {

    public static void main(String[] args) {

        inputInfo(new Scanner(System.in));
    }

    /**
     * 输出信息方法
     *
     * @param in Scanner
     */
    private static void inputInfo(Scanner in) {
        while (true) {
            System.out.println("请选择想要制作的披萨:1 培根披萨 2 海鲜披萨  3退出程序");
            int cho = in.nextInt();
            switch (cho) {
                case 1:
                    BaconPizzaIn(in).show();
                    break;
                case 2:
                    SeafoodPizzaIn(in).show();
                    break;
                case 3:
                    System.out.println("退出程序!!!");
                    System.exit(0);
                default:
                    System.out.println("输入范围不合法");
                    break;
            }
        }


    }

    /**
     * 创建培根披萨
     *
     * @param in
     * @return 披萨子类--自动向上转型为披萨
     */
    private static Pizza BaconPizzaIn(Scanner in) {
        System.out.println("请输入培根克数:");
        double grams = in.nextDouble();
        System.out.println("请输入披萨大小:");
        double size = in.nextDouble();
        System.out.println("请输入披萨价格:");
        double price = in.nextDouble();
        return new BaconPizza("培根披萨", price, size, grams);
    }

    /**
     * 创建海鲜披萨
     *
     * @param in
     * @return 披萨子类--自动向上转型为披萨
     */
    private static Pizza SeafoodPizzaIn(Scanner in) {
        System.out.println("请输入配料信息:");
        String ingredients = in.next();
        System.out.println("请输入披萨大小:");
        double size = in.nextDouble();
        System.out.println("请输入披萨价格:");
        double price = in.nextDouble();
        return new SeafoodPizza("海鲜披萨", price, size, ingredients);
    }
}
